const goodsModel = require('../models/goods')

exports.classify = async (req, res, next) => {
    let result = await goodsModel.classifyList()
    if (result) {
      res.json(result)
    } else {
      // res.render('fail', {
      //   data: JSON.stringify({
      //     message: '获取数据失败。'
      //   })
      // })
      res.json({
        code:-1,
        message:"获取数据失败"
      })
    }
  }

  
  exports.add_classify = async (req, res, next) => {
    res.set('content-type', 'application/json; charset=utf-8')
    let result = await goodsModel.add_classify({
        ...req.body,
      })
    if (result) {
      res.json({
        code:0,
        message:"添加成功"
      })
    } else {
      res.json({
        code:-1,
        message:"添加失败"
      })
    }
  }

  exports.good_detail = async (req, res, next) => {
    res.set('content-type', 'application/json; charset=utf-8')
    let result = await goodsModel.good_detail({
        ...req.body,
      })
    if (result) {
      res.json(result)
    } else {
      res.json({
        code:-1,
        message:"获取信息失败"
      })
    }
  }


